import {Modal, Notice,} from "obsidian";

import MyPlugin from "../../../main";

// 添加页面的操作
export function 解密文件输入密码的弹框(this_:MyPlugin){
	// 打开一个弹框
	this_.addCommand({
		id: 'sjz-open-1213',
		name: 'sjz-输入密码解密文件',
		callback: () => {
			new SampleModal1(this_.app).open();
		}
	});
}

export default class SampleModal1 extends Modal {
	onOpen() {
		const {contentEl} = this;
		contentEl.createEl('h1', {text: '打开一个弹框'});
		const input = contentEl.createEl('input', {
			type: 'text',
			placeholder: '请输入密码'
		});
		input.addEventListener('input', (e) => {
			if (e.target instanceof HTMLInputElement) {
				// new Notice(e.target.value);
			}
		});

		const confirmButton = contentEl.createEl('button', {
			text: '点击确定',
			cls: 'my-confirm-button' // Add a custom CSS class
		});

		// Listen to click event on the confirm button
		confirmButton.addEventListener('click', () => {
			// Handle confirm button click
			const inputValue = input.value;
			new Notice(inputValue);
		});

		// Listen to keydown event for Enter key
		input.addEventListener('keydown', (e) => {
			if (e.key === 'Enter') {
				// Handle Enter key press
				const inputValue = input.value;
				new Notice(inputValue);
			}
		});
	}
}
